<?php
/**
 * 账单
 */
namespace App\Validation;

use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Numericality;
use Phalcon\Validation\Validator\InclusionIn;

class MemberLogAppValidation extends BaseValidation
{
	public function initialize()
	{
		$this->add(
			"table_id",
			new Numericality(
				  [
					  "message" => ":field is not numeric",
					  "allowEmpty" => true,
				  ]
			)
		);

		$this->add(
			"pos",
			new InclusionIn(
				  [
					  "field" => "pos",
					  "domain" => [1,2,3,4,5],//1登录,2搜索关键词,3停留页面,4支付,5浏览记录
					  "message" => ":field is not included in 1 or 2 or 3 or 4 or 5",
				  ]
			)
		);

		$this->add(
			"p",
			new Numericality(
				  [
					  "message" => ":field is not numeric",
				  ]
			)
		);
		
		$this->add(
			"page_num",
			new Numericality(
				  [
					  "message" => ":field is not numeric",
				  ]
			)
		);
	}

	//验证之前
	public function beforeValidation($data, $entity, $messages)
    {
        parent::beforeValidation($data, $entity, $messages);
        
        return true;
    }
}